<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
		/*
			1! = 1 * 1
			2! = 1 * 2
			3! = 1 * 2 * 3
			4! = 1 * 2 * 3 * 4
			*/
			//声明一个函数，输入一个整数n, 返回 1!+2!+3!+4!+…n!，另外再使用1个函数封装n!。
			
			function jc(n) {
				var sum = 1;
				for (var i = 1; i <= n; i++) {//每个数的乘积
					sum = sum * i;
				}return sum;
			}
			
			
			function fz(n){
				var sum2 = 0;
				for(var i = 1; i <= n; i++){//n个数的阶层相加
					sum2 = sum2 + jc(i);
				}return sum2;
			}
			console.log(jc(4));
			console.log(fz(2));
		</script>
	</body>
</html>
